<?php
	class Default_Blocks_MenuLeft extends Zend_View_Helper_Abstract{
		public function menuLeft(){ 
			$cate = new Default_Model_Category();
			$list_cate = $cate->getAll();
			$view = $this->view;
			
			$menu = $this->createMenu($list_cate,0, $view);
			require_once ('MenuLeft/Views.php');
		}
		public function createMenu($sourceArr, $parents = 0, $viewObj) {
	        $this->recursiveMenu($sourceArr, $parents = 0, &$newMenu, $viewObj);
	        return str_replace('<ul></ul>', '', $newMenu);
	    }
		public function recursiveMenu($sourceArr, $parents = 0, &$newMenu, $viewObj) {
	        $filter = new Zend_Filter();
//	        $multiFilter = $filter->addFilter(new Zendvn_Filter_RemoveCircumflex())
//	                ->addFilter(new Zend_Filter_StringToLower(array('encoding' => 'UTF-8')))
//	                ->addFilter(new Zend_Filter_Alnum(true))
//	                ->addFilter(new Zend_Filter_PregReplace(array('match' => '#\s+#', 'replace' => '-')))
//	                ->addFilter(new Zend_Filter_Word_SeparatorToDash());
	        if (count($sourceArr) > 0) {
	        	
	            $idUL = 'ulGroup_' . $parents;
	            
	            foreach ($sourceArr as $key => $value) {
	            	
	                if ($value['parentId'] == $parents) {
	                    $liMenu = 'liMenu_' . $value['id'];
	                    if ($value['parentId'] == 0) {
	                    	$newMenu .= '
				            <div class="lefttitle">'.$value['titleVi'].
				            '</div>'; 
	                    } elseif($value['level'] < 3) {
	                        $link = BASE_URL;
	                        $newMenu .= '<ul id="' . $idUL . '">
	                        <li ><a href="' . $link . '" id="' . $liMenu . '">' . $value['titleVi'] . '</a>';
	                    }
	
	                    $newParents = $value['id'];
	                    unset($sourceArr[$key]);
	                    $this->recursiveMenu($sourceArr, $newParents, $newMenu, $viewObj);
	                    $newMenu .= '</li></ul>';
	                }
	            }
	            
	        }
	    }
	}
?>